package com.shop.user;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

import com.shop.user.common.MyMapper;
import com.shop.utils.JwtUtil;
import com.shop.utils.SnowflakeIdWorker;

import tk.mybatis.spring.annotation.MapperScan;

@SpringBootApplication
@EnableEurekaClient //微服务都是Eureka客户端，所以加这个注解
@EnableFeignClients //用到Feign的话这个必须写
@EnableHystrix //开启熔断，如果有feignclient调用的话
@MapperScan(basePackages = "com.shop.user.dao", markerInterface = MyMapper.class)
public class UserApplication {

	public static void main(String[] args) {
		SpringApplication.run(UserApplication.class, args);
	}

	@Bean
	public SnowflakeIdWorker idWorkker(){
		return new SnowflakeIdWorker(1, 1);
	}

	@Bean
	public BCryptPasswordEncoder encoder(){
		return new BCryptPasswordEncoder();
	}

	@Bean
	public JwtUtil jwtUtil(){
		return new JwtUtil();
	}
}
